package com.bang.springcloud.report.controller;


import com.bang.framework.base.response.Result;
import com.bang.springcloud.report.entity.Order;
import com.bang.springcloud.report.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.bang.framework.base.response.BaseController;

/**
 * <p>
 * 订单 前端控制器
 * </p>
 *
 * @author bang
 * @since 2019-12-10
 */
@RestController
@RequestMapping("/order")
public class OrderController extends BaseController {

    @Autowired
    private IOrderService orderService;


    @PostMapping("/add")
    public Result createOrder(@RequestBody Order order) {
        try {
            orderService.createOrder(order);
        } catch (Exception e) {
            e.printStackTrace();
            return resultFail("添加失败").setData(e.getMessage());
        }
        return resultSuccess("添加成功").setData(order.getOrderNo());
    }

}
